Skip to content

FIX: convert each Py-ART Grid only once in get_dd_wind_field - #172

Merged
rcjackson merged 1 commit into
openradar:mainfrom
Wahaj18:fix-167-pyart-grid-list
Nov 11, 2026
Merged

rcjackson merged 1 commit into
openradar:mainfrom
Wahaj18:fix-167-pyart-grid-list

Conversation

@Wahaj18

@Wahaj18 Wahaj18 commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Closes #167

get_dd_wind_field converted a list of Py-ART Grids inside a redundant outer loop:

for x in Grids:
    new_grids = [read_from_pyart_grid(x) for x in Grids]

so every grid went through read_from_pyart_grid once per grid in the list. That conversion pops data from the Grid's radar_latitude/radar_longitude/radar_altitude dicts, so the second pass over the first grid fails with KeyError: 'data'. In practice, passing two or more Py-ART Grids straight to get_dd_wind_field always failed. Lists of xarray Datasets and a single Py-ART Grid were not affected.

This PR drops the outer loop so each grid is converted once.

Testing: added test_list_of_pyart_grids, which passes two Py-ART test grids to get_dd_wind_field. It fails on main with KeyError: 'data' and passes with this change. The rest of test_cost_functions.py, test_initialization.py and test_retrieval.py passes locally on the SciPy engine (Jax/TensorFlow tests skipped). I left out test_get_iem_data (network) and test_twpice_case_parallel (dask), and the two HRRR tests fail only because cfgrib isn't installed in my environment. ruff and black are clean on the changed files.

A list of Py-ART Grids was converted inside a redundant outer loop, so
every grid went through read_from_pyart_grid once per grid in the list.
The conversion pops the radar location data from the Grid, so the second
pass raised KeyError: 'data' for any list of two or more Py-ART Grids.

Closes openradar#167
@rcjackson

Copy link
Copy Markdown
Collaborator

Hello. Can you explain why you did what you did?

@rcjackson
rcjackson merged commit 2ef0657 into openradar:main Nov 11, 2026
@Wahaj18

Wahaj18 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging! Quick summary: get_dd_wind_field had a redundant outer loop (for x in Grids: new_grids = [read_from_pyart_grid(x) for x in Grids]), so each Py-ART Grid was converted once per grid in the list. read_from_pyart_grid pops data from the grid's radar_latitude/radar_longitude/radar_altitude dicts, so the second pass over the same grid raised KeyError: 'data'. That meant passing two or more Py-ART Grids directly always failed. Dropping the outer loop converts each grid once, and the new test_list_of_pyart_grids covers that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in get_dd_wind_field

2 participants